<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
    <head>
        <title>用户登录</title>
        <script src="js/jquery-3.4.1.min.js"></script>
        <script>
            $(function () {
                $("#regist").click(function () {
                    window.location.href = "/user/toRegist";
                })
            })
            function submit () {
                alert("执行了")
                var username=$("#username").val();
                var password=$("#password").val();
                alert(username);
                $.ajax({
                    url: "/user/login",
                    type: "post",
                    data: {
                        username:username,
                        password:password
                    },
                    dataType: "text",
                    success: function (text) {
                        if (text == "success") {
                            alert("登录成功！")
                        }
                    }
                })

            };
        </script>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    </head>
    <body>
        <div>
            <div> <a href="index.html"></a></div>
            姓名：<input id="username" type="text" name="username" /><br/>
            密码：<input id="password" type="password" name="password" /><br/>
            <button type="submit" id="login" onclick="submit()">提交</button>
            <button id="regist" type="button" >注册</button>
        </div>
    </body>
</html>

